package boxe.timer.media;

/**
 * play sound media and manage other media flows 
 * 
 * @author Julien Perriard
 * @date 18.05.2010
 * 
 */


import java.io.File;
import java.io.IOException;

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;

public class MediaTimer {
	private enum type {
		TEXT, AUDIO, VIDEO
	}
	private String startSoundFile;
	private String stopSoundFile;
	private String videoFile;
	private String textFile;
	private String imageFile;
	
		
			public void playSound(String filename) {
				Clip clip;
				File file;
				AudioInputStream ain;
				try {
					if(filename != null && !filename.isEmpty()){
						file = new File(filename); 
						ain = AudioSystem.getAudioInputStream(file);
			            DataLine.Info info =  
			            	new DataLine.Info(Clip.class,ain.getFormat( ));
			            clip = (Clip) AudioSystem.getLine(info);
			            clip.open(ain);
			            clip.start();
			            ain.close( );
					}
		        } catch (LineUnavailableException e) {
					e.printStackTrace();
		        } catch (UnsupportedAudioFileException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				}
	}


			public String getStartSoundFile() {
				return startSoundFile;
			}


			public void setStartSoundFile(String startSoundFile) {
				this.startSoundFile = startSoundFile;
			}
			
			public String getStopSoundFile() {
				return stopSoundFile;
			}


			public void setStopSoundFile(String stopSoundFile) {
				this.stopSoundFile = stopSoundFile;
			}


			public String getVideoFile() {
				return videoFile;
			}


			public void setVideoFile(String videoFile) {
				this.videoFile = videoFile;
			}


			public String getTextFile() {
				return textFile;
			}


			public void setTextFile(String textFile) {
				this.textFile = textFile;
			}


			public String getImageFile() {
				return imageFile;
			}


			public void setImageFile(String imageFile) {
				this.imageFile = imageFile;
			}
}
